package controllers

import (
	"blog_api/models"
	"github.com/gin-gonic/gin"
	"strconv"
	"strings"
)

type SetController struct {
	BaseController
}

func (s SetController) AdminSetList(c *gin.Context) {
	keyword := strings.TrimSpace(c.DefaultQuery("keyword", ""))
	page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
	limit, _ := strconv.Atoi(c.DefaultQuery("limit", "13"))

	offset := (page - 1) * limit
	list, total := models.AdminSetList(limit, offset, "*", keyword)
	data := make(map[string]interface{})
	data["list"] = list
	data["total"] = total
	s.success(c, "success", data)
	return
}